package main

import "fmt"

type MethodUtils struct {
}

type Cal struct {
	num1 float64
	num2 float64
}

func (m MethodUtils) Print() {
	for i := 0; i < 10; i++ {
		for j := 0; j < 8; j++ {
			fmt.Print(" *")
		}
		fmt.Println()
	}
}

func (m MethodUtils) Printn(n1, n2 int) {
	for i := 0; i < n1; i++ {
		for j := 0; j < n2; j++ {
			fmt.Print(" *")
		}
		fmt.Println()
	}
}

func (m *MethodUtils) Print9(n int) {
	if n < 1 || n > 9 {
		return
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%d*%d=%d ", j, i, i*j)
		}
		fmt.Println()
	}
}

func (m *MethodUtils) Transfer(arr *[3][3]int) {
	var newArr [3][3]int
	for i := 0; i < len(arr[0]); i++ {
		for j := 0; j < len(arr); j++ {
			newArr[i][j] = arr[j][i]
		}
	}

	for i := 0; i < len(newArr); i++ {
		fmt.Println(newArr[i])
	}
}

func (cal *Cal) calcu(op byte) float64 {
	res := .0
	switch op {
	case '+':
		res = cal.num1 + cal.num2
	case '-':
		res = cal.num1 - cal.num2
	case '*':
		res = cal.num1 * cal.num2
	case '/':
		res = cal.num1 / cal.num2
	}
	return res
}
func main() {
	var m MethodUtils
	m.Print()

	fmt.Println("--------------------")
	m.Printn(3, 2)
	fmt.Println("--------------------")

	cal := Cal{10, 20}
	fmt.Println((&cal).calcu('+'))
	fmt.Println((&cal).calcu('-'))
	fmt.Println((&cal).calcu('*'))
	fmt.Println((&cal).calcu('/'))

	fmt.Println("--------------------")

	// 99 乘法表
	// var num int
	// fmt.Scanf("%d", &num)
	// m.Print9(num)

	fmt.Println("--------------------")

	arr := [3][3]int{
		{1, 2, 3},
		{4, 5, 6},
		{7, 8, 9},
	}

	m.Transfer(&arr)

}
